package com.starlink.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.starlink.model.domain.MallPeripherySpecificationDO;
import com.starlink.model.request.MallPeripherySpecificationRequest;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author zhanghong
 */
@Repository
public interface MallPeripherySpecificationMapper extends BaseMapper<MallPeripherySpecificationDO> {
    MallPeripherySpecificationDO selectDOById(Long id);
    List<MallPeripherySpecificationDO> selectDOList(MallPeripherySpecificationDO mallPeripherySpecification);
    int insertDO(MallPeripherySpecificationDO mallPeripherySpecification);
    int batchInsertDO(List<MallPeripherySpecificationDO> mallPeripherySpecificationDOList);
    int updateDO(MallPeripherySpecificationDO mallPeripherySpecification);
    int deleteDOById(Long id);
    int deleteDOByIds(String[] ids);

    @Select({"<script>",
            "   select count(1) from mall_periphery_specification",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "</script>"})
    long pageCount(@Param("param") MallPeripherySpecificationRequest param);
    @Select({"<script>",
            "   select * from mall_periphery_specification",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "   order by create_time desc limit #{limit} offset #{offset}",
            "</script>"})
    List<MallPeripherySpecificationDO> pageQuery(@Param("param") MallPeripherySpecificationRequest param, @Param("limit") int limit, @Param("offset") long offset);

    void deletedByPerId(@Param("perId") Long perId);

    MallPeripherySpecificationDO selectFirstByPeripheryId(@Param("peripheryId")Long peripheryId);

    void updateQuantity(Map<String, Long> quantityMap);

    void deletedByPerIds(String[] ids);

    void addQuantity(Map<String, Long> map);
}
